import 'package:json_annotation/json_annotation.dart';

part 'session.g.dart';

@JsonSerializable()
class SaTokenInfo {
  String tokenName;
  String tokenValue;
  bool isLogin;
  dynamic loginId;
  String loginType;
  int tokenTimeout;
  int sessionTimeout;
  int tokenSessionTimeout;
  int tokenActiveTimeout;
  String loginDeviceType;
  String? tag;

  SaTokenInfo({
    required this.tokenName,
    required this.tokenValue,
    required this.isLogin,
    required this.loginId,
    required this.loginType,
    required this.tokenTimeout,
    required this.sessionTimeout,
    required this.tokenSessionTimeout,
    required this.tokenActiveTimeout,
    required this.loginDeviceType,
    this.tag,
  });

  factory SaTokenInfo.fromJson(Map<String, dynamic> json) => _$SaTokenInfoFromJson(json);
  Map<String, dynamic> toJson() => _$SaTokenInfoToJson(this);
}

@JsonSerializable()
class User {
  int? id;
  String? username;
  int? gender;
  String? phoneNumber;
  String? email;
  DateTime? birthDate;
  String? avatar;
  List<String>? area;
  String? address;
  String? job;
  List<String>? tags;
  String? description;

  User({
    this.id,
    this.username,
    this.gender,
    this.phoneNumber,
    this.email,
    this.birthDate,
    this.avatar,
    this.area,
    this.address,
    this.job,
    this.tags,
    this.description,
  });

  factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
  Map<String, dynamic> toJson() => _$UserToJson(this);
}

@JsonSerializable()
class Session {
  SaTokenInfo saToken;
  User userInfo;

  Session({required this.saToken, required this.userInfo});

  factory Session.fromJson(Map<String, dynamic> json) => _$SessionFromJson(json);
  Map<String, dynamic> toJson() => _$SessionToJson(this);
}
